package com.jjc.android.adapter

import android.util.SparseArray
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jjc.android.R
import com.jjc.android.activity.VideoPlayerActivity
import com.jjc.android.entity.CommonQuestionDto
import com.jjc.android.entity.VideoDto
import com.jjc.android.util.showImage

class CommonQuestionAdapter : BaseQuickAdapter<CommonQuestionDto,BaseViewHolder>(R.layout.item_common_question) {

    init {
        setOnItemClickListener { _, _, position ->
            expandStatus.put(position,expandStatus[position]!=true)
            notifyItemChanged(position)
        }
    }

    private val expandStatus:SparseArray<Boolean> = SparseArray()

    override fun convert(helper: BaseViewHolder, item: CommonQuestionDto) {
        val isExpand = expandStatus[helper.adapterPosition]==true
        val expandTxt = helper.getView<TextView>(R.id.expandTxt)
        expandTxt.visibility = if(isExpand) View.VISIBLE else View.GONE
        helper.setText(R.id.newsTitleText,item.vxuqvzuiokgnk8la)
        expandTxt.text = item.jsonMember1nagigka1p37iqm9
        helper.getView<View>(R.id.arrowImage).isActivated = isExpand
    }

}